# -*- coding: utf-8 -*-
# @Time    : 2019/2/27 15:35
# @Author  : Macher
# @File    : multirbl_feature.py
# @Software: PyCharm Community Edition
# 从mul中提取特征，查看频率数量
import mysql.connector
import time
import threading
config = {'host': '219.216.65.41',
          'user': 'root',
          'password': '123456',
          'port': 3306,
          'database': 'mydata',
          'charset': 'utf8'}

def sql():
    l = []
    conn = mysql.connector.connect(**config)
    cursor = conn.cursor()
    cursor.execute("SELECT multirbl FROM experiment_date WHERE multirbl !='' and multirbl is not null  ")
    results = cursor.fetchall()
    new = []
    d1 = {}
    for row in results:
        for item in  row[0].split('&&'):
            if d1.has_key(item):
                temp = d1[item]
                temp += 1
                d1[item] = temp
            else:
                d1[item] = 1
    for k in sorted(d1, key=d1.__getitem__):
        print(k, d1[k])
    #     row = "".join(row[0])
    #     new.append(row)
    # new = list(set(new))
    cursor.close()
    conn.commit()
    conn.close()
    return new
sql()